window.addEvent('domready', function() {
	if ($('type') && $('edit-question-form')) {
		var type = $('type').value;
		if (type == 'radio' || type == 'checkbox' || type == 'rate'
				|| type == 'dropdown') {
			showAnswers();
		}
	}
});

function change(sid,sec,num) {
	var sid = sid
	var sec = sec
	var num = num
	redirect("survey/preview.php?sid=" + sid + "&sec=" + sec + "&num=" + num);
}

function showAnswers() {
	$('answer-choices').className = '';
}

function hideAnswers() {
	$('answer-choices').className = 'invisible';
}

function showFrequency(target) {
	alert(target.value);
	$('frequency').className = '';
	$('select_date').className = 'invisible';
	$('select_day').className = 'invisible';
	$('date1').className = 'invisible';
	$('date2').className = 'invisible';
}

function showDate() {
	$('select_date').className = '';
	$('frequency').className = '';
	$('select_day').className = 'invisible';
	$('date1').className = 'invisible';
	$('date2').className = 'invisible';
}

function showDay() {
	$('select_day').className = '';
	$('frequency').className = '';
	$('select_date').className = 'invisible';
	$('date1').className = 'invisible';
	$('date2').className = 'invisible';

}

function showFixedDate() {
	$('date1').className = '';
	$('date2').className = '';
	$('select_date').className = 'invisible';
	$('select_day').className = 'invisible';
	$('frequency').className = 'invisible';

}

function showRequired() {
	$('required').className = '';
	$('create_section').className = 'invisible';

}

function showSection() {
	$('required').className = 'invisible';
	$('create_section').className = '';

}

function checkAll(num) {
	for ( var i = 1; i < num + 1; i++) {
		var check_box = 'check_' + i;
		if ($(check_box)) {
			$(check_box).checked = 'checked';
		}
		if ($(check_box) && $('check_all').checked == '') {
			$(check_box).checked = '';
		}
	}
}

function uncheckAll(num) {
	for ( var i = 1; i < num + 1; i++) {
		var check_box = 'check_' + i;
		if ($(check_box)) {
			$(check_box).checked = '';
		}
	}
}